package com.level2app.ui.welcome.view;

import androidx.lifecycle.MutableLiveData;

import com.level2app.base.BaseViewModel;
import com.level2app.bean.CheckReferralCodeBean;
import com.level2app.bean.MessageBean;
import com.level2app.di.retrofit.BaseNetCallback;

import java.util.HashMap;
import java.util.Map;


/**
 * Created by S
 * time 2024/8/13
 */
public class ReferralCodeViewModel extends BaseViewModel {

    public MutableLiveData<String> mInputData = new MutableLiveData<>();

    public MutableLiveData<CheckReferralCodeBean> checkReferralCodeData = new MutableLiveData<>();

    public void checkReferralCode() {
        Map<String, Object> map = new HashMap<>();
        map.put("referral_code", mInputData.getValue());
        addSubscribe(mRetrofitHelper.checkReferralCode(map).subscribeWith(new BaseNetCallback<CheckReferralCodeBean>(){

            @Override
            public void onSuccess(CheckReferralCodeBean baseModel) {
                checkReferralCodeData.setValue(baseModel);
            }

            @Override
            public void onError(String message) {
                super.onError(message);
                mErrorData.setValue(message);
            }
        }));
    }
}